//
//  BaseRequestPlugin.swift
//  MT
//
//  Created by zhang qiang on 2018/11/21.
//  Copyright © 2018年 张强. All rights reserved.
//

import UIKit
import Moya
import Result

open class BaseRequestPlugin: NSObject, PluginType {
    
    let viewController: UIViewController
    
    public init(viewController: UIViewController) {
        self.viewController = viewController
    }
    public override init() {
        self.viewController = UIViewController()
        super.init()
    }
    
    public func willSend(_ request: RequestType, target: TargetType) {
        
    }
    
    public func didReceive(_ result: Result<Moya.Response, MoyaError>, target: TargetType) {
        //only continue if result is a failure
        guard case Result.failure(_) = result else { return }
        
        debugPrint("result.error?.response?.statusCode :", result.error?.response?.statusCode ?? "")
        
//        result.error?.response?.statusCode
//        error.response?.statusCode ?? 0
    }
}
